<template>
  <div class="dashboard-editor-container">
    <github-corner class="github-corner" />
    <div>
      <el-card class="box-card" style="width: 100%;">
        <el-avatar size="large" :src="avatar" class="user-avatar"></el-avatar>
        <span style="font-size: 25px;font-weight: bold;margin: 10px">您好！管理员:</span>
        <span style="font-size: 25px;font-weight: bold;margin: 10px">{{ name }}</span>
        <span style="font-size:20px;padding-top:20px;display:inline-block;float: right">个人简介：{{ introduction }}</span>
      </el-card>
    </div>

    <panel-group @handleSetLineChartData="handleSetLineChartData" />

    <notice />

    <el-row :gutter="32" style="margin-top: 10px">
      <el-col :xs="24" :sm="24" :lg="32">
        <div class="chart-wrapper">
          <el-tag type="success" style="font-weight: bold;font-size: 20px;margin-bottom: 2px">上周考勤情况</el-tag>
          <bar-chart />
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import GithubCorner from '@/components/GithubCorner'
import PanelGroup from './components/PanelGroup'
import BarChart from './components/BarChart'
import Notice from '@/views/dashboard/notice'
import { mapGetters } from 'vuex'

const lineChartData = {
  newVisitis: {
    expectedData: [100, 120, 161, 134, 105, 160, 165],
    actualData: [120, 82, 91, 154, 162, 140, 145]
  },
  messages: {
    expectedData: [200, 192, 120, 144, 160, 130, 140],
    actualData: [180, 160, 151, 106, 145, 150, 130]
  },
  purchases: {
    expectedData: [80, 100, 121, 104, 105, 90, 100],
    actualData: [120, 90, 100, 138, 142, 130, 130]
  },
  shoppings: {
    expectedData: [130, 140, 141, 142, 145, 150, 160],
    actualData: [120, 82, 91, 154, 162, 140, 130]
  }
}

export default {
  name: 'DashboardAdmin',
  components: {
    GithubCorner,
    PanelGroup,
    BarChart,
    Notice
  },
  data() {
    return {
      lineChartData: lineChartData.newVisitis
    }
  },
  computed: {
    ...mapGetters([
      'name',
      'avatar',
      'roles',
      'introduction'
    ])
  },
  methods: {
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type]
    }
  },
  created() {
    this.$notify.success({
      title: '欢迎',
      message: '欢迎访问星人事管理系统',
      duration: 0
    });
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(244, 246, 248);
  position: relative;

  .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  }

  .chart-wrapper {
    background: #ffffff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
  .user-avatar {
    cursor: pointer;
    width: 80px;
    height: 70px;
    border-radius: 10px;
  }
}

@media (max-width:1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
